package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.IntegralItem;
import cn.wolfcode.crm.query.IntegralItemQueryObject;
import cn.wolfcode.crm.query.JSONResult;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.service.IIntegralItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("integralItem")
public class IntegralItemController {

    @Autowired
    private IIntegralItemService integralItemService;

    //由于dataGrid组件返回必须为json,所以跳转界面就分开
    @RequestMapping("view")
    public String view(){
        return "integralitem";
    }


   //页面数据
    @RequestMapping("query")
    @ResponseBody
    public PageResult query(IntegralItemQueryObject qo){
        return integralItemService.query(qo);
    }

    //积分充值操作
    @RequestMapping("save")
    @ResponseBody
    public JSONResult save(IntegralItem item){
        JSONResult result = new JSONResult();
        try{
            integralItemService.save(item);
        }catch (Exception e){
            e.printStackTrace();
            result.mark(e.getMessage());
        }
        return result;
    }
}
